import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    name: "lf",
    age: 18,
    fruit: "apple"
  },
  getters: {
    getterFruit(state) {
      return `I like ${state.fruit}`
    },
    getAge(state) {
      return `I am ${state.age} years old.`
    }
  },
  mutations: {
    changeFruit(state, preload) {
      state.fruit = preload.fruit
    },
    changeAge(state, preload) {
      state.fruit = preload.age
    }
  }
})

export default store;